-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
STYLE Reduce merge conflicts with force_single_line
#50275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
force_single_line
We aren't back porting this right? |
I think we could just apply the same change to 1.5.x, so:
Or waiting until there's no more 1.5.x releases would be fine too |
Agree, don't want to do this on 1.5.x. Lets wait till we are through there |
sure, marking as draft til then |
force_single_line
force_single_line
Would it make sense to replace isort with reorder_python_imports? I believe we would get the same style but benefit from reorder_python_imports's import re-writing. |
|
Does isort allow us to undo this if we ultimately want to revert? +/-0 on this but feels a bit strange since a user wouldn't naturally write or read code this way |
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
We could just remove the option, and then it would go back to how it was before Do users often write or read imports anyway though? I think most contributors just put the import somewhere at the top and then just let isort take care of where and how to place it |
39ceeb7
to
3287ced
Compare
force_single_line
force_single_line
0b629b9
to
5ce3a07
Compare
@mroeschke @lithomas1 thoughts on getting this in before the RC? Exact commands I ran to do this:
The third commit was to fix this unwanted pattern pandas/.pre-commit-config.yaml Lines 269 to 271 in fe85cbf
which, given the current import style, wasn't actually being caught most of the time |
5ce3a07
to
505820e
Compare
IMO I don't think this should go into the RC yet. Since this is a style change that touches a lot of files, I think there should be a few more positive responses before committing to this. |
The goal here is to remove merge conflicts (in the longer term). Of course while there are backport branches active with these changes this would increase the probability of a merge conflict. So probably best to do it now (and also apply the change script to 2.0.x now separately) since perhaps it should have been done before the rc. If we need to do another 1.5.x release then we would maybe have a few merge conflicts to resolve. I am generally +1 on this change. |
Thanks! Gonna do a @pandas-dev/pandas-core ping then to hear people's opinions Motivation for why to do this is to further reduce merge conflicts, see #50274 for a concrete example of how it would help |
I find this style really un-natural from a coding standpoint. Using VSCode, imports are sometimes automatically inserted at the top. I understand the motivation. So I'm -1 on it, because it makes the imports look "noisy", but won't stand in the way. Wondering if a solution is to resolve merge conflicts in backports by round-tripping through this idea. In other words, we keep the style as it currently is, and then when merging, convert the target to this style and the part being merged to this style, do the merge, and then convert the merged part back to the existing style. Not sure if this idea is even feasible. |
Not sure what you mean, sorry - what's the issue with that? You'll need to run isort/pre-commit anyway |
I would also say it looks unnatural and I'm not aware of any human writing style that adopts this. Do you have a sense as to how often this would reduce/avoid merge conflicts? It feels like it would roughly on par, in terms of avoiding merge conflicts, as something like from lib import (
a,
b,
c,
) which is already in use in lots of places. |
I give an example here: #50274 (comment) . I haven't counted how often this happens, but I opened the issue after having to manually fix imports in several backports when the conflict was just due to going from a single import to multiple
It's in place everywhere - the issue is in going from
to
|
Perhaps a less unnatural-looking alternative would be to use
even for single imports. I'll open a separate PR to demonstrate that EDIT: here it is: #51693 |
I'm not sure of a specific example, but there are times where I'm writing code where I use something that has no |
ew, gross. |
The pain point for merge conflicts is in the whatsnew. id love to see a tool for that. (Also for filling in an issue reference when i dont know the number until i open a pr) |
the whatsnew conflicts are orthogonal- but I agree, it would be good to address those too
😆 not sure why people don't like this style, but OK, I don't want to force it. Would you be OK with #51693 instead? |
closing in favour of #51693, which looks like it might have a non-zero chance of passing
here you go https://ichard26.github.io/next-pr-number/ |
force_single_line
orforce_grid_wrap=1
#50274 (Replace xxxx with the GitHub issue number)doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Exact commands I ran to do this:
I then added a handful of missing
noqa: F401
(which you can check in the second commit)To check that there's nothing unrelated, you could do:
and check that the only diff is a handful of
noqa: F401
comments andimport pandas._testing as tm
changesPerformance is unaffected, here some results:
Another result:
In short - it doesn't make a difference to performance